package com.znz.analysis.ceph;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.ceph.rados.IoCTX;
import com.ceph.rados.Rados;
import com.ceph.rados.exceptions.RadosException;
import com.ceph.rbd.Rbd;
import com.ceph.rbd.RbdException;
import com.ceph.rbd.RbdImage;

@Deprecated
public class CephUtil {

	public static void read(String fileName) throws RbdException, RadosException, IOException {
		Rados rados = new Rados("admin");
		File file = new File("/etc/ceph/ceph.conf");
		rados.confReadFile(file);
		rados.connect();
		IoCTX ioctx = rados.ioCtxCreate("jewelbox");
		Rbd rbd = new Rbd(ioctx);
		RbdImage image = rbd.open(fileName);

		int chunkSize = 1024 * 3;
		long offset = 0;
		byte[] buffer = new byte[chunkSize];

		File f = new File("/home/share/" + fileName);
		if (f.exists()) {
			f.delete();
		}
		FileOutputStream out = new FileOutputStream(f, true);
		while (image.read(offset, buffer, buffer.length) > 0) {
			out.write(buffer);
			buffer = new byte[chunkSize];
			offset += chunkSize;
		}
		out.flush();
		out.close();
	}

	public static void main(String[] args) throws RbdException, RadosException, IOException {
		String[] array = { "2017-06-13-0000-2330_.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_.mobo360.com.cn.log.gz", "2017-06-13-0000-2330_.wabuw.com.cn.log.gz",
				"2017-06-13-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-13-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-13-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-13-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_nodomain20170609.yesip.com.cn.log.gz",
				"2017-06-13-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-13-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-13-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_p2ppay.mobaopay.com.cn.log.gz", "2017-06-13-0000-2330_pay.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-13-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-13-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-13-0000-2330_www.wabuw.com.cn.log.gz",
				"2017-06-13-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz",
				"2017-06-14-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-14-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-14-0000-2330_.wabuw.com.cn.log.gz", "2017-06-14-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-14-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-14-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-14-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_nodomain20170609.yesip.com.cn.log.gz",
				"2017-06-14-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-14-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-14-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_p2ppay.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-14-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-14-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-14-0000-2330_www.wabuw.com.cn.log.gz",
				"2017-06-14-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz",
				"2017-06-15-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-15-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-15-0000-2330_.wabuw.com.cn.log.gz", "2017-06-15-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-15-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-15-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-15-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-15-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-15-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-15-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-15-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-15-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-15-0000-2330_www.wabuw.com.cn.log.gz", "2017-06-16-0000-2330_.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_.mobo360.com.cn.log.gz", "2017-06-16-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-16-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-16-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-16-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-16-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-16-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-16-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_p2ppay.mobaopay.com.cn.log.gz", "2017-06-16-0000-2330_pay.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-16-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-16-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-16-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz",
				"2017-06-17-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-17-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-17-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-17-0000-2330_api.sztdcoin.com.cn.log.gz", "2017-06-17-0000-2330_m.scxsdz.com.cn.log.gz",
				"2017-06-17-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-17-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-17-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-17-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-17-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-17-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-17-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-17-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-17-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-18-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-18-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-18-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-18-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-18-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-18-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-18-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-18-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-18-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_p2ppay.mobaopay.com.cn.log.gz", "2017-06-18-0000-2330_pay.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-18-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-18-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-19-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-19-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-19-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-19-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-19-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_m.scxsdz.com.cn.log.gz",
				"2017-06-19-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-19-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-19-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-19-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_p2ppay.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-19-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-19-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-19-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz",
				"2017-06-20-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-20-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-20-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-20-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-20-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_cbpaycashier.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_m.scxsdz.com.cn.log.gz",
				"2017-06-20-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-20-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-20-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-20-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-20-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-20-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-20-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz",
				"2017-06-21-0000-2330_.mobaopay.com.cn.log.gz", "2017-06-21-0000-2330_.mobo360.com.cn.log.gz",
				"2017-06-21-0000-2330_aedu17010501.tcpsec.com.cn.log.gz",
				"2017-06-21-0000-2330_api.sztdcoin.com.cn.log.gz",
				"2017-06-21-0000-2330_cbpayadmin.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_cbpaymerchant.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_m.scxsdz.com.cn.log.gz", "2017-06-21-0000-2330_mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_nodomain20161110.yesip.com.cn.log.gz",
				"2017-06-21-0000-2330_nodomain20170610.yesip.com.cn.log.gz",
				"2017-06-21-0000-2330_nodomain5.yesip.com.cn.log.gz", "2017-06-21-0000-2330_p2p.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_p2ppay.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_saasadmin.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_saascashier.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_saasmerchant.mobaopay.com.cn.log.gz",
				"2017-06-21-0000-2330_www.mobaopay.com.cn.log.gz", "2017-06-21-0000-2330_www.sztdcoin.com.cn.log.gz",
				"2017-06-21-0000-2330_yajiao16122801.tcpsec.com.cn.log.gz" };
		for (String s : array) {
			read(s);
		}
		System.out.println("end");
	}
}
